﻿import Vue from "/vue/libs/vue.esm.browser.min.js";
import Element from "/vue/el/index.esm.browser.js";
import Cookies from "/vue/libs/js.cookie.esm.browser.js";
import store from '/vue/store/index.js'
import router from '/vue/router/index.js'
import * as filters from "/vue/filters/index.js";
import "/vue/site/permission.js";
import { mockXHR } from '/mock/index.js';
import { isDemo } from '/vue/utils/validate.js';

window.Vue = Vue;//为上下文菜单组件动态生成时使用
if (isDemo()) {
	mockXHR()
	hasSystemPage = true;
}

Vue.use(Element, {
	size: Cookies.get('size') || 'medium' // set element-ui default size
});

// 全局注册svg图标组件
Vue.component('svg-icon', () => httpVueLoaderWrap("/vue/components/svgicon/index.vue"));
// 全局注册sp-contextmenu, 把集成在el中的上下文组件拿出来放到组件库并做一定修改
httpVueLoaderWrap("/vue/components/contextmenu/index.vue").then(m => {
	Vue.component("sp-contextmenu", m);
});
// 全局注册SimpleChart
httpVueLoaderWrap("/vue/components/charts/schart/index.vue").then(m => {
	Vue.component("simple-chart", m);
});

Object.keys(filters).forEach(key => {
	Vue.filter(key, filters[key])
});

httpVueLoader.install(Vue);

new Vue({
	router,
	store,
	_baseURI: "/",//httpVueLoader加载时使用
	data: {
		
	},
	computed: {		
	},
	watch: {
		$route: {
			handler: function (route) {
				const query = route.query;
				otherQuery = this.getOtherQuery(query);
			},
			immediate: false//第一次的值不监听
		}
	},
	mounted() {
		
	},
	methods: {
		getOtherQuery(query) {
			return Object.keys(query).reduce((acc, cur) => {
				if (cur !== 'redirect') {
					acc[cur] = query[cur]
				}
				return acc
			}, {})
		}
	}
}).$mount("#app");